package com.ruoyi.project.configureSystem.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.configureSystem.domain.VDatatype;
import com.ruoyi.project.configureSystem.service.IVDatatypeService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 工艺类型查询Controller
 * 
 * @author wangshuo
 * @date 2021-01-08
 */
@RestController
@RequestMapping("/configureSystem/processtype")
public class VDatatypeController extends BaseController
{
    @Autowired
    private IVDatatypeService vDatatypeService;

    /**
     * 查询工艺类型查询列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:list')")
    @GetMapping("/list")
    public TableDataInfo list(VDatatype vDatatype)
    {
        startPage();
        List<VDatatype> list = vDatatypeService.selectVDatatypeList(vDatatype);
        return getDataTable(list);
    }

    /**
     * 导出工艺类型查询列表
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:export')")
    @Log(title = "工艺类型查询", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(VDatatype vDatatype)
    {
        List<VDatatype> list = vDatatypeService.selectVDatatypeList(vDatatype);
        ExcelUtil<VDatatype> util = new ExcelUtil<VDatatype>(VDatatype.class);
        return util.exportExcel(list, "processtype");
    }

    /**
     * 获取工艺类型查询详细信息
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(vDatatypeService.selectVDatatypeById(id));
    }

    /**
     * 新增工艺类型查询
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:add')")
    @Log(title = "工艺类型查询", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VDatatype vDatatype)
    {
        return toAjax(vDatatypeService.insertVDatatype(vDatatype));
    }

    /**
     * 修改工艺类型查询
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:edit')")
    @Log(title = "工艺类型查询", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VDatatype vDatatype)
    {
        return toAjax(vDatatypeService.updateVDatatype(vDatatype));
    }

    /**
     * 删除工艺类型查询
     */
    @PreAuthorize("@ss.hasPermi('configureSystem:processtype:remove')")
    @Log(title = "工艺类型查询", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(vDatatypeService.deleteVDatatypeByIds(ids));
    }

    /**
     * 查询工艺类型查询列表
     */
    @GetMapping("/getProcessTypeByStationcode")
    public AjaxResult getProcessTypeByStationcode(String stationcode)
    {
        List<VDatatype> list = vDatatypeService.getProcessTypeByStationcode(stationcode);
        return AjaxResult.success(list);
    }
}
